# 测试文件


def test_vid_util():
    # aid, bvid 转换工具
    from utils.vid_util import av2bv, bv2av

    print(av2bv(111298867365120) == "BV1L9Uoa9EUx")  # True
    print(bv2av("BV1L9Uoa9EUx") == 111298867365120)  # True


def test_wbi_tuil():
    # wbi 签名工具
    import asyncio
    import urllib.parse

    from utils.wbi_util import enc_wbi, get_wbi_keys

    img_key, sub_key = asyncio.run(get_wbi_keys())
    print(img_key, sub_key)

    params = {"foo": "114", "bar": "514", "baz": 114514}

    signed_params = enc_wbi(params=params, img_key=img_key, sub_key=sub_key)
    print(signed_params)

    query = urllib.parse.urlencode(signed_params)
    print(query)


def test_zone_util():
    # 分区相关工具
    from utils.zone_util import (
        get_all_zones,
        get_code_by_tid,
        get_name_by_code,
        get_name_by_tid,
        get_ranking_zones,
        get_tid_by_code,
        get_zone_by_tid,
        get_zones_sorted_by_tid,
        is_valid_code,
        is_valid_tid,
    )

    # print(get_all_zones())
    # print(get_ranking_zones())
    # print(get_zones_sorted_by_tid())
    print(get_zone_by_tid(1005))
    print(get_name_by_tid(1005))
    print(get_code_by_tid(1005))
    print(get_tid_by_code("donghua"))
    print(get_name_by_code("vlog"))
    print(is_valid_code("balala"))
    print(is_valid_tid(100000))


if __name__ == "__main__":
    # vid_util
    # test_vid_util()

    # wbi_util
    # test_wbi_tuil()

    # zone_util
    # test_zones_util()

    pass
